#include <iostream>

#include "screenCredit.hpp"

using namespace std;
using namespace sf;

ScreenCredit::ScreenCredit() {
	mySplash.LoadFromFile("res/saber.gif");
	mySplashSpr.SetTexture(mySplash);

	/* Positioning... */
	mySplashSpr.SetX( (GetSize().x - mySplash.GetWidth()) /2 );
	mySplashSpr.SetY( (GetSize().y - mySplash.GetHeight())/2 );
	Attach(mySplashSpr, layers(0));

	Trigger( layers(0), fade_out, 500, 2000);
	_next = 0;
}

ScreenCredit::~ScreenCredit() {

}

void ScreenCredit::GetEvent( sf::Event& e) {
	if ( e.Type == Event::KeyPressed ) {
		switch(e.Key.Code) {
			default: // any key 
			{
				if ( GetTime() > 1000 ) _next = 1;
			} break;
		}
	}
}

int ScreenCredit::Update() {
	if ( GetTime() > 3000 || _next == 1 )
		return update_die;
	return update_alive;
}
